package com.moive.news.tqnewsapplication.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.ProgressBar;

import com.moive.news.tqnewsapplication.R;
import com.moive.news.tqnewsapplication.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/12/13.
 */
public class AboutActivity extends BaseActivity {
    @BindView(R.id.about_back)
    ImageView aboutBack;
    @BindView(R.id.about_webView)
    WebView aboutWebView;
    @BindView(R.id.webview_pro)
    ProgressBar webviewPro;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        aboutBack.setOnClickListener(v -> finish());
        aboutWebView.getSettings().setJavaScriptEnabled(true);
        aboutWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                aboutWebView.loadUrl(url);
                return true;
            }
        });
        aboutWebView.loadUrl("http://www.tqiant.com/index.html#intro");
        aboutWebView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 100) {
                    webviewPro.setVisibility(View.GONE);
                } else {
                    webviewPro.setProgress(newProgress);
                }
            }
        });
    }
}
